import numpy as np
from PIL import Image, ImageDraw


def create_sickle_mask(size=800):
    """创建镰刀形状的蒙版"""
    # 创建空白图片
    mask = Image.new('L', (size, size), 0)
    draw = ImageDraw.Draw(mask)

    # 绘制镰刀形状
    # 1. 绘制圆形部分
    center = (size // 2, size // 2)
    radius = size // 3
    draw.ellipse((center[0] - radius, center[1] - radius,
                  center[0] + radius, center[1] + radius),
                 fill=255)

    # 2. 绘制镰刀刀身
    # 使用贝塞尔曲线绘制镰刀刀身
    points = [
        (center[0] + radius // 2, center[1] - radius // 2),  # 起点
        (center[0] + radius, center[1] - radius),  # 控制点1
        (center[0] + radius * 1.5, center[1]),  # 控制点2
        (center[0] + radius, center[1] + radius)  # 终点
    ]
    draw.line(points, fill=255, width=radius // 2)

    return mask


if __name__ == '__main__':
    # 创建镰刀形状蒙版
    mask = create_sickle_mask()
    # 保存为PNG文件
    mask.save('sickle_mask.png')